﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 开放封闭原则.终极版
{
    /*符合单一职责，开闭原则 。但是switch并没有解决*/
    public interface IBankProcess
    {
        void Process();
    }
    public class Deposite : IBankProcess
    {
        public void Process()
        {
            Console.WriteLine("存款");
        }
    }
    public class DrowMoney : IBankProcess
    {
        public void Process()
        {
            Console.WriteLine("取款");
        }
       
    }
    public class BuyJiJin : IBankProcess
    {
        public void Process()
        {
            Console.WriteLine("购买基金");
        }
    }
    public class Transfer : IBankProcess
    {
        public void Process()
        {
            Console.WriteLine("转账");
        }
    }


    public class BankStuff3
    {
        private IBankProcess _bankProcess ;
        public void HandleProcess(BankClient bankClient)
        {

            //调用银行的业务系统，处理我们用户的需求；
            switch (bankClient.BankType)
            {
                case "存款":
                    _bankProcess=new Deposite();
                    _bankProcess.Process();
                    break;
                case "取款":
                    _bankProcess = new DrowMoney();
                    _bankProcess.Process();
                    break;
                case "转账":
                    _bankProcess = new Transfer();
                    _bankProcess.Process();
                    break;
                case "购买基金":
                    _bankProcess = new BuyJiJin();
                    _bankProcess.Process();
                    break;
                default:
                    Console.WriteLine("没有办法处理您的业务");
                    break;
            }
        }
    }
}
